home *** CD-ROM | disk | FTP | other *** search
- /*
- File: SoundComponents.h
-
- Contains: Sound Components Interfaces.
-
- Version: Technology: System 7.5
- Release: Universal Interfaces 3.0d3 on Copland DR1
-
- Copyright: © 1984-1996 by Apple Computer, Inc. All rights reserved.
-
- Bugs?: If you find a problem with this file, send the file and version
- information (from above) and the problem description to:
-
- Internet: apple.bugs@applelink.apple.com
- AppleLink: APPLE.BUGS
-
- */
- #ifndef __SOUNDCOMPONENTS__
- #define __SOUNDCOMPONENTS__
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
- #ifndef __COMPONENTS__
- #include <Components.h>
- #endif
- #ifndef __SOUND__
- #include <Sound.h>
- #endif
-
- #ifdef __cplusplus
- extern "C" {
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import on
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=mac68k
- #endif
-
- /*
- * * * N O T E * * *
-
- This file has been updated to include Sound Manager 3.1 interfaces.
-
- Some of the Sound Manager 3.0 interfaces were not put into the InterfaceLib
- that originally shipped with the PowerMacs. These missing functions and the
- new 3.1 interfaces have been released in the SoundLib library for PowerPC
- developers to link with. The runtime library for these functions are
- installed by Sound Manager 3.1. The following functions are found in SoundLib.
-
- AudioGetBass, AudioGetInfo, AudioGetMute, AudioGetOutputDevice,
- AudioGetTreble, AudioGetVolume, AudioMuteOnEvent, AudioSetBass,
- AudioSetMute, AudioSetToDefaults, AudioSetTreble, AudioSetVolume,
- OpenMixerSoundComponent, CloseMixerSoundComponent, SoundComponentAddSource,
- SoundComponentGetInfo, SoundComponentGetSource, SoundComponentGetSourceData,
- SoundComponentInitOutputDevice, SoundComponentPauseSource,
- SoundComponentPlaySourceBuffer, SoundComponentRemoveSource,
- SoundComponentSetInfo, SoundComponentSetOutput, SoundComponentSetSource,
- SoundComponentStartSource, SoundComponentStopSource
- */
-
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- constants
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- sound component types and subtypes
- */
-
- enum {
- kNoSoundComponentType = '****',
- kSoundComponentType = 'sift', /*component type*/
- kSoundComponentPPCType = 'nift', /*component type for PowerPC code*/
- kRate8SubType = 'ratb', /*8-bit rate converter*/
- kRate16SubType = 'ratw', /*16-bit rate converter*/
- kConverterSubType = 'conv', /*sample format converter*/
- kSndSourceSubType = 'sour', /*generic source component*/
- kMixerType = 'mixr',
- kMixer8SubType = 'mixb', /*8-bit mixer*/
- kMixer16SubType = 'mixw', /*16-bit mixer*/
- kSoundOutputDeviceType = 'sdev', /*sound output component*/
- kClassicSubType = 'clas', /*classic hardware, i.e. Mac Plus*/
- kASCSubType = 'asc ', /*Apple Sound Chip device*/
- kDSPSubType = 'dsp ', /*DSP device*/
- kAwacsSubType = 'awac', /*Another of Will's Audio Chips device*/
- kGCAwacsSubType = 'awgc', /*Awacs audio with Grand Central DMA*/
- kSingerSubType = 'sing', /*Singer (via Whitney) based sound*/
- kSinger2SubType = 'sng2', /*Singer 2 (via Whitney) for Acme*/
- kWhitSubType = 'whit', /*Whit sound component for PrimeTime 3*/
- kSoundBlasterSubType = 'sbls', /*Sound Blaster for CHRP*/
- kSoundCompressor = 'scom',
- kSoundDecompressor = 'sdec',
- kMace3SubType = 'MAC3', /*MACE 3:1*/
- kMace6SubType = 'MAC6', /*MACE 6:1*/
- kCDXA4SubType = 'cdx4', /*CD/XA 4:1*/
- kCDXA2SubType = 'cdx2', /*CD/XA 2:1*/
- kIMA4SubType = 'ima4', /*IMA 4:1*/
- kULawSubType = 'ulaw', /*µLaw 2:1*/
- kLittleEndianSubType = 'sowt', /*Little-endian*/
- kAudioComponentType = 'adio', /*Audio components and sub-types*/
- kAwacsPhoneSubType = 'hphn',
- kAudioVisionSpeakerSubType = 'telc',
- kAudioVisionHeadphoneSubType = 'telh',
- kPhilipsFaderSubType = 'tvav'
- };
-
- /*sound component set/get info selectors*/
-
- enum {
- siVolume = 'volu',
- siHardwareVolume = 'hvol',
- siSpeakerVolume = 'svol',
- siHeadphoneVolume = 'pvol',
- siHardwareVolumeSteps = 'hstp',
- siHeadphoneVolumeSteps = 'hdst',
- siHardwareMute = 'hmut',
- siSpeakerMute = 'smut',
- siHeadphoneMute = 'pmut',
- siRateMultiplier = 'rmul',
- siQuality = 'qual',
- siWideStereo = 'wide',
- siHardwareFormat = 'hwfm',
- siPreMixerSoundComponent = 'prmx',
- siPostMixerSoundComponent = 'psmx',
- kOffsetBinary = 'raw ', /*format types*/
- kTwosComplement = 'twos',
- kMACE3Compression = 'MAC3',
- kMACE6Compression = 'MAC6'
- };
-
- /*features flags*/
-
- enum {
- k8BitRawIn = (1 << 0), /*data description*/
- k8BitTwosIn = (1 << 1),
- k16BitIn = (1 << 2),
- kStereoIn = (1 << 3),
- k8BitRawOut = (1 << 8),
- k8BitTwosOut = (1 << 9),
- k16BitOut = (1 << 10),
- kStereoOut = (1 << 11),
- kReverse = (1L << 16), /* function description*/
- kRateConvert = (1L << 17),
- kCreateSoundSource = (1L << 18),
- kHighQuality = (1L << 22), /* performance description*/
- kNonRealTime = (1L << 23)
- };
-
- #if FOR_SYSTEM7_AND_SYSTEM8_DEPRECATED
- /*SoundComponentPlaySourceBuffer action flags*/
-
- enum {
- kSourcePaused = (1 << 0),
- kPassThrough = (1L << 16),
- kNoSoundComponentChain = (1L << 17)
- };
-
- /*flags for OpenMixerSoundComponent*/
-
- enum {
- kNoMixing = (1 << 0), /*don't mix source*/
- kNoSampleRateConversion = (1 << 1), /*don't convert sample rate (i.e. 11 kHz -> 22 kHz)*/
- kNoSampleSizeConversion = (1 << 2), /*don't convert sample size (i.e. 16 -> 8)*/
- kNoSampleFormatConversion = (1 << 3), /*don't convert sample format (i.e. 'twos' -> 'raw ')*/
- kNoChannelConversion = (1 << 4), /*don't convert stereo/mono*/
- kNoDecompression = (1 << 5), /*don't decompress (i.e. 'MAC3' -> 'raw ')*/
- kNoVolumeConversion = (1 << 6), /*don't apply volume*/
- kNoRealtimeProcessing = (1 << 7) /*won't run at interrupt time*/
- };
-
- /*SoundParamBlock quality flags*/
-
- enum {
- kBestQuality = (1 << 0) /*use interpolation in rate conversion*/
- };
-
- /*useful bit masks*/
-
- enum {
- kInputMask = 0x000000FF, /*masks off input bits*/
- kOutputMask = 0x0000FF00, /*masks off output bits*/
- kOutputShift = 8, /*amount output bits are shifted*/
- kActionMask = 0x00FF0000, /*masks off action bits*/
- kSoundComponentBits = 0x00FFFFFF
- };
-
- /*Audio Component constants*/
-
- enum {
- /*Values for whichChannel parameter*/
- audioAllChannels = 0, /*All channels (usually interpreted as both left and right)*/
- audioLeftChannel = 1, /*Left channel*/
- audioRightChannel = 2, /*Right channel*/
- /*Values for mute parameter*/
- audioUnmuted = 0, /*Device is unmuted*/
- audioMuted = 1, /*Device is muted*/
- /*Capabilities flags definitions*/
- audioDoesMono = (1L << 0), /*Device supports mono output*/
- audioDoesStereo = (1L << 1), /*Device supports stereo output*/
- audioDoesIndependentChannels = (1L << 2) /*Device supports independent software control of each channel*/
- };
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- typedefs
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
- /*
- ShortFixed consists of an 8 bit, 2's complement integer part in the high byte,
- with an 8 bit fractional part in the low byte; its range is -128 to 127.99609375
- */
- typedef short ShortFixed;
- typedef struct SoundParamBlock SoundParamBlock;
- typedef SoundParamBlock *SoundParamBlockPtr;
- typedef pascal Boolean (*SoundParamProcPtr)(SoundParamBlockPtr *pb);
-
- #if GENERATINGCFM
- typedef UniversalProcPtr SoundParamUPP;
- #else
- typedef SoundParamProcPtr SoundParamUPP;
- #endif
- struct SoundParamBlock {
- long recordSize; /*size of this record in bytes*/
- SoundComponentData desc; /*description of sound buffer*/
- UnsignedFixed rateMultiplier; /*rate multiplier to apply to sound*/
- short leftVolume; /*volumes to apply to sound*/
- short rightVolume;
- long quality; /*quality to apply to sound*/
- ComponentInstance filter; /*filter to apply to sound*/
- SoundParamUPP moreRtn; /*routine to call to get more data*/
- SoundParamUPP completionRtn; /*routine to call when buffer is complete*/
- long refCon; /*user refcon*/
- short result; /*result*/
- };
-
- /*private thing to reference a Sound Source*/
- typedef struct OpaqueSoundSource* SoundSource;
- typedef SoundSource *SoundSourcePtr;
- struct SoundComponentLink {
- ComponentDescription description; /*Describes the sound component*/
- SoundSource mixerID; /*Reserved by Apple*/
- SoundSource * linkID; /*Reserved by Apple*/
- };
- typedef struct SoundComponentLink SoundComponentLink;
-
- typedef SoundComponentLink *SoundComponentLinkPtr;
- struct AudioInfo {
- long capabilitiesFlags; /*Describes device capabilities*/
- long reserved; /*Reserved by Apple*/
- unsigned short numVolumeSteps; /*Number of significant increments between min and max volume*/
- };
- typedef struct AudioInfo AudioInfo;
-
- typedef AudioInfo *AudioInfoPtr;
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- functions for sound components
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Sound Component dispatch selectors
- */
-
- enum {
- kSoundComponentInitOutputDeviceSelect = 1, /*these calls cannot be delegated*/
- kSoundComponentSetSourceSelect = 2,
- kSoundComponentGetSourceSelect = 3,
- kSoundComponentGetSourceDataSelect = 4,
- kSoundComponentSetOutputSelect = 5,
- kDelegatedSoundComponentSelectors = 0x0100, /*first selector that can be delegated up the chain*/
- /*these calls can be delegated and have own range*/
- kSoundComponentAddSourceSelect = kDelegatedSoundComponentSelectors + 1,
- kSoundComponentRemoveSourceSelect = kDelegatedSoundComponentSelectors + 2,
- kSoundComponentGetInfoSelect = kDelegatedSoundComponentSelectors + 3,
- kSoundComponentSetInfoSelect = kDelegatedSoundComponentSelectors + 4,
- kSoundComponentStartSourceSelect = kDelegatedSoundComponentSelectors + 5,
- kSoundComponentStopSourceSelect = kDelegatedSoundComponentSelectors + 6,
- kSoundComponentPauseSourceSelect = kDelegatedSoundComponentSelectors + 7,
- kSoundComponentPlaySourceBufferSelect = kDelegatedSoundComponentSelectors + 8
- };
-
-
- enum {
- /*Audio Component selectors*/
- kAudioGetVolumeSelect = 0,
- kAudioSetVolumeSelect = 1,
- kAudioGetMuteSelect = 2,
- kAudioSetMuteSelect = 3,
- kAudioSetToDefaultsSelect = 4,
- kAudioGetInfoSelect = 5,
- kAudioGetBassSelect = 6,
- kAudioSetBassSelect = 7,
- kAudioGetTrebleSelect = 8,
- kAudioSetTrebleSelect = 9,
- kAudioGetOutputDeviceSelect = 10,
- kAudioMuteOnEventSelect = 129
- };
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- Sound Manager 3.0 utilities
- */
- extern pascal OSErr OpenMixerSoundComponent(SoundComponentDataPtr outputDescription, long outputFlags, ComponentInstance *mixerComponent)
- FOURWORDINLINE(0x203C, 0x0614, 0x0018, 0xA800);
-
- extern pascal OSErr CloseMixerSoundComponent(ComponentInstance ci)
- FOURWORDINLINE(0x203C, 0x0218, 0x0018, 0xA800);
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- basic sound component functions
- */
- extern pascal ComponentResult SoundComponentInitOutputDevice(ComponentInstance ti, long actions)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0001, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentSetSource(ComponentInstance ti, SoundSource sourceID, ComponentInstance source)
- FIVEWORDINLINE(0x2F3C, 0x0008, 0x0002, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentGetSource(ComponentInstance ti, SoundSource sourceID, ComponentInstance *source)
- FIVEWORDINLINE(0x2F3C, 0x0008, 0x0003, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentGetSourceData(ComponentInstance ti, SoundComponentDataPtr *sourceData)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0004, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentSetOutput(ComponentInstance ti, SoundComponentDataPtr requested, SoundComponentDataPtr *actual)
- FIVEWORDINLINE(0x2F3C, 0x0008, 0x0005, 0x7000, 0xA82A);
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- junction methods for the mixer, must be called at non-interrupt level
- */
- extern pascal ComponentResult SoundComponentAddSource(ComponentInstance ti, SoundSource *sourceID)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0101, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentRemoveSource(ComponentInstance ti, SoundSource sourceID)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0102, 0x7000, 0xA82A);
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- info methods
- */
- extern pascal ComponentResult SoundComponentGetInfo(ComponentInstance ti, SoundSource sourceID, OSType selector, void *infoPtr)
- FIVEWORDINLINE(0x2F3C, 0x000C, 0x0103, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentSetInfo(ComponentInstance ti, SoundSource sourceID, OSType selector, void *infoPtr)
- FIVEWORDINLINE(0x2F3C, 0x000C, 0x0104, 0x7000, 0xA82A);
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- control methods
- */
- extern pascal ComponentResult SoundComponentStartSource(ComponentInstance ti, short count, SoundSource *sources)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0105, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentStopSource(ComponentInstance ti, short count, SoundSource *sources)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0106, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentPauseSource(ComponentInstance ti, short count, SoundSource *sources)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0107, 0x7000, 0xA82A);
-
- extern pascal ComponentResult SoundComponentPlaySourceBuffer(ComponentInstance ti, SoundSource sourceID, SoundParamBlockPtr pb, long actions)
- FIVEWORDINLINE(0x2F3C, 0x000C, 0x0108, 0x7000, 0xA82A);
-
- /*
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- interface for Audio Components
- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- */
- /*
- Volume is described as a value between 0 and 1, with 0 indicating minimum
- volume and 1 indicating maximum volume; if the device doesn't support
- software control of volume, then a value of unimpErr is returned, indicating
- that these functions are not supported by the device
- */
- extern pascal ComponentResult AudioGetVolume(ComponentInstance ac, short whichChannel, ShortFixed *volume)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0000, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioSetVolume(ComponentInstance ac, short whichChannel, ShortFixed volume)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0001, 0x7000, 0xA82A);
-
- /*
- If the device doesn't support software control of mute, then a value of unimpErr is
- returned, indicating that these functions are not supported by the device.
- */
- extern pascal ComponentResult AudioGetMute(ComponentInstance ac, short whichChannel, short *mute)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0002, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioSetMute(ComponentInstance ac, short whichChannel, short mute)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0003, 0x7000, 0xA82A);
-
- /*
- AudioSetToDefaults causes the associated device to reset its volume and mute values
- (and perhaps other characteristics, e.g. attenuation) to "factory default" settings
- */
- extern pascal ComponentResult AudioSetToDefaults(ComponentInstance ac)
- FIVEWORDINLINE(0x2F3C, 0x0000, 0x0004, 0x7000, 0xA82A);
-
- /*This routine is required; it must be implemented by all audio components*/
- extern pascal ComponentResult AudioGetInfo(ComponentInstance ac, AudioInfoPtr info)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0005, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioGetBass(ComponentInstance ac, short whichChannel, short *bass)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0006, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioSetBass(ComponentInstance ac, short whichChannel, short bass)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0007, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioGetTreble(ComponentInstance ac, short whichChannel, short *Treble)
- FIVEWORDINLINE(0x2F3C, 0x0006, 0x0008, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioSetTreble(ComponentInstance ac, short whichChannel, short Treble)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x0009, 0x7000, 0xA82A);
-
- extern pascal ComponentResult AudioGetOutputDevice(ComponentInstance ac, Component *outputDevice)
- FIVEWORDINLINE(0x2F3C, 0x0004, 0x000A, 0x7000, 0xA82A);
-
- /*This is routine is private to the AudioVision component. It enables the watching of the mute key.*/
- extern pascal ComponentResult AudioMuteOnEvent(ComponentInstance ac, short muteOnEvent)
- FIVEWORDINLINE(0x2F3C, 0x0002, 0x0081, 0x7000, 0xA82A);
-
-
-
-
- enum {
- uppSoundParamProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(Boolean)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(SoundParamBlockPtr *)))
- };
-
- #if GENERATINGCFM
- #define NewSoundParamProc(userRoutine) \
- (SoundParamUPP) NewRoutineDescriptor((ProcPtr)(userRoutine), uppSoundParamProcInfo, GetCurrentArchitecture())
- #else
- #define NewSoundParamProc(userRoutine) \
- ((SoundParamUPP) (userRoutine))
- #endif
-
- #if GENERATINGCFM
- #define CallSoundParamProc(userRoutine, pb) \
- CallUniversalProc((UniversalProcPtr)(userRoutine), uppSoundParamProcInfo, (pb))
- #else
- #define CallSoundParamProc(userRoutine, pb) \
- (*(userRoutine))((pb))
- #endif
- #endif
-
- #if PRAGMA_ALIGN_SUPPORTED
- #pragma options align=reset
- #endif
-
- #if PRAGMA_IMPORT_SUPPORTED
- #pragma import off
- #endif
-
- #ifdef __cplusplus
- }
- #endif
-
- #endif /* __SOUNDCOMPONENTS__ */
-
-